pub mod types {

    use std::io;
    use std::collections::HashMap;

    pub fn tup_fn() {
        let tup:(i32, u8, f32) = (13, 1, 6.4);
        //格式化打印数据:#?
        println!("data is {:#?}", tup);
        //取对应的索引直接.index
        println!("data[0] is {}", tup.0);
    }

    pub fn array_pue() {
        let tup = [1,2,3,4];
        println!("data is {:#?}", tup);
        println!("data[1] is {}", tup[1]);
    }

    pub fn borrow_ver() {
        let mut x = 5;
        //借用修改成功
        let y = &mut x;
        *y += 1;
        println!("value {}", x)
    }

    pub fn ver_live() {
        //不建议这样做，因为x的生命周期没有y的生命周期长
        let y :i32;
        let x = 4;
        y = x;

        println!("value {}", y);
    }

    pub fn borrow_ver_domain() {
        let mut x = 5;
        //借用修改成功，主要是对值的引用，更好的限定作用域的问题
        {
            let y = &mut x;
            *y += 1;
        }
        println!("value {}", x)
    }

    pub fn change_ver() {
        let mut x = 5;
        x += 2;
        {
            let y = &mut x;
            *y += 1;
            println!("value y {}", y);
        }
        x += 1;
        println!("value x {}", x);
    }

    pub struct Vars {
        data: String,
        con: u8,
        live: bool,
    }

    pub fn new_var(name: String, is: bool) -> Vars {
        Vars {
            data: name,
            con: 1,
            live: is,
        }
    }

    impl Vars {

        pub fn let_mut(&self) {
            let mut v = vec!("hello", "world");
            println!("vec content {} {}", v[0], v[1]);
            let content = &v[0];
            self.let_fn(content);
            v.push("today");
            println!("all content {:?}", v)
        }

        fn let_fn(&self, con: &str) {
            println!("print_content {}", con);
        }

        pub fn let_num(&self) -> u8 {
            let mut content: String = String::new();
            io::stdin().read_line(&mut content)
                .ok()
                .expect("IT is wrong");
            println!("read content {}", content);
            let num = content.trim().parse().unwrap();
            num
        }

        pub fn let_for(&self) -> HashMap<String, String> {
            let content = self.data.clone();
            let mut map: HashMap<String, String> = HashMap::new();
            if content.len() > 0 {
                let vec: Vec<&str> = content.split("-").collect();
                for v in vec {
                    map.insert(v.to_string().to_uppercase(), v.to_string());
                }
            }
            return map;
        }

        pub fn check_live(&self) -> String {
            match self.con {
                1 => return self.data.clone(),
                _ => return "none".to_string(),
            }
        }
    }
}